"""
Use to look into, and check the contents of an egg...

python -m viewegg egg file1 dir2
egg is an egg
file1 is a file in the egg
dir2 is a directory containing a version of file1 outside the egg (for comparison)
"""

from zipfile import ZipFile
from sys import argv, stdout
from difflib import Differ

if len(argv)==3:
   print ZipFile(argv[1]).read(argv[2])
elif len(argv)==2:
   ZipFile(argv[1]).printdir()
elif len(argv)==4:
   text1 = [s+'\n' for s in ZipFile(argv[1]).read(argv[2]).split('\n')]
   text2 = open(argv[3]+argv[2]).readlines()
   stdout.writelines( list(Differ().compare(text1, text2)) )
